// 病人收费

import React from 'react';
import moment from 'moment';
import { Select, Input, Row, Col, Button, Spin, message, Table, Tabs, Modal, Divider,DatePicker,Switch } from 'antd';
import { $http } from 'containers/config/https';
import HopNumber from './component/HopNumber'
import HistoryModal from './component/HistoryModal'
import { $loadTemplate } from '../../lodop/Common/Print.js';
import ReadCard from '../../../components/readcard/ReadCard';
import store from '../../../store';
import './style/style.less'
import '../../opadmReg/style/index.less';
import { Keup, ArraySome, Verification, INSUYBUtil } from '../../../tools/index';
// import TipHeader from './component/TipHeader';
import PatPayModal from './component/PatPayModal';
import RangeDatePicker from 'components/rangePicker/index';
import { Util,dayFormat, timeFormat } from 'tools/index';
import ShowFaceRecognitionModal from 'pages/workstation/component/ShowFaceRecognitionModal';
import PatientAdmOrderCharges from '../Report/PatientAdmOrderCharges'
import PublicModalTable from 'pages/common/PublicModalTable';
// import OtherCashRegister from './component/js/OtherCashRegister.jsx'

import avatarFemale from 'assets/images/avatar_female.png';
import avatarMale from 'assets/images/avatar_male.png';

// 组件const
const { Option } = Select;
const TabPane = Tabs.TabPane;
// const { RangePicker } = DatePicker;
// const dateFormat = 'YYYY-MM-DD' || undefined;
const { Search } = Input;

export default class PatientCharges extends React.Component {

	constructor(props) {
		super(props)
		this.updateParent = this.updateParent.bind(this);
		this.MakeMoney = this.MakeMoney.bind(this);
		let userData = JSON.parse(sessionStorage.getItem('userData'));
		this.state = {
			userData,
			dataPatChar: [], // 挂号table数据
			dataAdmReason: [], // 费用类型table数据
			userInfo: {}, // 用户数据
			modalShow: false, //  弹框的显示
			modalShowPay: false, //  收银弹框的显示
			modalPayTitle: '请输入社保卡密码', // 收银弹框的标题
			patNo: '', // 登记号
			cardNo: '', // 卡号
			cardType: '', // 卡类型
			invoice: '', // 发票
			cardTypeData: [], // 卡类型
			settlementTypeData: [], // 结算类型
			IfAllAdmPay: '', // 是否是多选
			columnsPatChar: [],// 费用类型table
			columnsPatCharSome: [],// 费用类型table
			allPrice: '0.00', // 费用总额
			allPatPrice: '0.00', // 病人应付金额
			orderAdmReason: [
				{ ordReasonID: '0', ordReasonDesc: "费用类型" } // 默认费用类型
			], // tab费用类型
			admIdStr: [], // 费用类型数组
			payButtonNum: 1,// 收银步骤
			modalShowPayWidth: '600px',// 收银宽度
			payrecordstr: [], // 付款记录表id串
			tabKey: 0,// 当前的tab页面key
			PayReasonDr: '',// 收费类型
			reasonCode:"",
			noJoinChargeOrderRowidStr: [], // 未选择的数组
			ipv4Adress: '',//id地址
			chargeRecodeId: '', // 交款记录id
			moneyData: {}, //金额对象
			otherPayData: [], //其他付款方式
			disabledInput: false, //收费权限
			IfSupplementOrd: 'none', //收费界面是否可以补录医嘱
			otherPay: '', //其他支付方式
			PayDis: false,
			otherPayDis: false, //其他支付方式不可选
			otherPayMoney: '0.00', // 其他支付金额
			cashInCashVal: '', // 实收现金
			zeroPay: '0.00', // 找零
			accountPayWayId: '', // 院内账户支付方式id
			payWayCashId: '', // 现金支付方式id
			otherPaywayId: '', // 其他付款方式id
			loadfalse: 'true', // 允许下一步
			unitsList: [], // 合作单位列表
			unitsListVal: '', //合作单位
			selectedRowKeys: [],
			selectedRowKeys2: [1],
			isListCheckload: [],//是否加载过
			admID: '', // 就诊id
			OPInsuType: '', //
			selecteId: '', //
			oldSelectedRowKeysArr: [],// 上一个选择数据
			activeKey: '0', //tab当前key
			findCondition: 'Y',
			StartDate: undefined,  // //开始日期
			EndDate: moment().format('YYYY-MM-DD'),  // //结束日期
			compleRecordIDinfo: '',  // //compleRecordIDinfo
			invIDinfo: '',  // //invIDinfo
			focusType: '',
			payType: '', // 付款方式
			maypayData: [],
			hzDis: false,
			payingAccountAmt: '0.00', // 初始payingAccountAmt
			languageData: {}, // 国际化语言包
			language: {},   // 国际化语言
			languageCode: JSON.parse(window.sessionStorage.userData).language, // 国际化语言标识
			readModeI: true,
			readModeR: true,
			modalShowHis: false,
			invNum: '0',
			password: '',
			personalData: '',
			qrCode: "",
			cardNumber: "",
			cardShow: false,
			insuReadFlag: "N",
			insuPayID: "",
			discountShow: false,
			modalPageSize: 10,
			modalPage: 1,
			modalData: [],
			INSUICDCode: '',    // 医保诊断code
			INSUICDDesc: '',    // 医保诊断描述
			xnhBCTYPE:'',
			xnhjgCode:'',
			xnhjgList: [],
			searchCode: '',
			comepnCodeList: [],
			comepnCode: '',
			divdata: [],		// 患者医保数据
			insuInfoShow: false,
			readCarddata: {},	// 读卡信息
			groupConfig: '',
			bankAmt: "0.00", // 银行卡支付金额
			QCCode: "",
			QCCodeShow: false,
			printNumber: 1,
			modalShowPrint: false,
			certType:"02",    //就诊凭证类型
			certNo:""  ,   //就诊凭证编号
			insuTypeList:[],
			insuType:"",            //险种类型
			insuMedTypeList:[],    //医疗类别
			insuMedType:"",
			diseCodeList:[],       //疾病编码
			birctrlTypeList:[],    //计划生育手术类别
			birctrlType:"",
			insuMdtrtGrpTypeList:[],//就诊人群类型
			insuMdtrtGrpType:"",
			diseDesc:"",
			diseCode:"",
			birctrlDate:"",
			userAccFlag:'Y',
			traumaFlag:'Y',
			thirdFlag:'Y',
			insuAdmdvs:""

		}
		this.modalColumns = [{
			title: 'ICD诊断代码',
			dataIndex: 'code',
			key: 'code'
		}, {
			title: 'ICD诊断描述',
			dataIndex: 'descripts',
			key: 'descripts'
		}]
		this.myRef1 = React.createRef();
		this.myRef2 = React.createRef();
		this.myRef3 = React.createRef();
		this.myRef4 = React.createRef();
		this.myRef5 = React.createRef();
		this.myRef6 = React.createRef();
	}

	componentDidMount() {

		for (var i = 0; i < document.querySelectorAll("div.maxHeight div.ant-table-body").length; i++) {
			document.querySelectorAll("div.maxHeight div.ant-table-body")[i].style.height = store.getState().tableHeight.y + 'px';
		}

		this.initJuris() //权限
		this.cardTypeList() //卡类型
		this.ordList1() //费用类型table
		this.ordList2() //费用类型table
		this.unitsList() //合作单位
		document.addEventListener("keydown", this.onKeyDown)

	}

	//监听键盘
	onKeyDown = (event) => {
		if (event.keyCode === 112) {  //屏蔽 F1
			event.preventDefault();
			if (!this.state.modalShowPay) {
				this.payButton()
			}
		}

		//屏蔽浏览器自带f1帮助
		window.onhelp = function () {
			return false;
		}

	}
	//获取光标
	focusInput = () => {

		let { focusType } = this.state
		if (focusType === 'CardNo') {
			const { input } = this.cardNoInput;
			input.focus();
		} else {
			const { input } = this.patNoInput;
			input.focus();
		}


	}

	// 历史记录子组件传值到父组件
	updateParent = (data) => {
		this.setState({
			admID: data.ID,
			patNo: data.PatNO,
		}, () => {
			this.searchUser('patNo')
			this.handleCancel() // 弹框关闭
		})
	}

	//算价格
	allPriceAdd = (selectedRows) => {
		let { allPrice, allPatPrice, payrecordstr, tabKey } = this.state
		payrecordstr = []
		allPrice = 0
		allPatPrice = 0
		selectedRows.map((item, i) => {
			allPrice += parseFloat(item.ordTotalAmt)
			allPatPrice += parseFloat(item.ordPatAmt)
			payrecordstr.push(item.ordID)// 付款记录表id串
		})
		this.setState({
			allPrice: allPrice.toFixed(2), // 费用总额
			allPatPrice: allPatPrice.toFixed(2),   // 病人应付金额
			payrecordstr: payrecordstr, // 付款记录表id串
		}, () => {
		})
	}



	rowSelectionOnChange = (selectedRowKeys2, selectedRows) => {
		let newSelectedRowKeys = selectedRowKeys2
		let selectedRowKeysArr = this.state.selectedRowKeys
		selectedRowKeysArr = newSelectedRowKeys

		let admIdStr = selectedRows.map((item, i) => {
			return item.admID
		})

		this.setState({
			admIdStr: admIdStr, //费用类型  数组
			selectedRowKeys2: selectedRowKeysArr,
			admID: admIdStr[0]
		}, () => {
			this.costTypeHttp('', '0', '', '') // 收费类型接口
		});
	}

	//checkChange
	onSelectChange = (selectedRowKeys, selectedRows) => {
		//ordSelect === 'N' ? true : false

		let newSelectedRowKeys = selectedRowKeys


		let { tabKey, oldSelectedRowKeysArr, dataAdmReason } = this.state

		let selectedRowKeysArr = this.state.selectedRowKeys

		//筛选新旧数组之间不同数据

		let list = ArraySome.getArrDifference(newSelectedRowKeys, oldSelectedRowKeysArr)


		let anyArr = dataAdmReason[tabKey].filter((item, i) => {
			return list.includes(item.key)


		})
		let anyordRelatedIDArr = anyArr.map((item, i) => {
			return item.ordPrescNoOrRelated
		})
		anyordRelatedIDArr = ArraySome.ArrayWeigh(anyordRelatedIDArr, 'remove') //将重复元素提取出到一个新数组或者单独数组去重
		anyordRelatedIDArr = anyordRelatedIDArr.filter(item => item) //去掉空字符串
		let selectedArr = dataAdmReason[tabKey].filter((item, i) => {
			if (item.ordSelect !== 'N') {
				return anyordRelatedIDArr.includes(item.ordPrescNoOrRelated)
			}

		})
		let endArr = selectedArr.map((item, i) => {
			return item.key
		})

		if (newSelectedRowKeys.length > oldSelectedRowKeysArr.length) {
			//说明是勾选
			newSelectedRowKeys = ArraySome.ArrayWeigh(newSelectedRowKeys.concat(endArr), 'remove')  // 合并去重

		} else {
			//说明是取消选中
			newSelectedRowKeys = newSelectedRowKeys.filter((item, i) => {
				return !endArr.includes(item)
			})


		}
		this.allPriceAdd(dataAdmReason[tabKey].filter((item, i) => {
			return newSelectedRowKeys.includes(item.key)
		}))  //算价格


		selectedRowKeysArr[tabKey] = newSelectedRowKeys  //最终选中的


		this.setState({
			selectedRowKeys: selectedRowKeysArr,
			oldSelectedRowKeysArr: newSelectedRowKeys
		})
	}



	// 权限
	initJuris = () => {
		var data = {
			params: [{
				logonHospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id
				logonGroupID: JSON.parse(window.sessionStorage.userData).groupID,  //角色id
				logonUserID: JSON.parse(window.sessionStorage.userData).userID, //人员id
				invTypeCode: 'O'  // 类型
			}]
		}
		$http.post('urlS', this, {
			code: "05210001",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {


					this.setState({
						invoice: res.currentInvNoInfo,  // 发票号
						IfAllAdmPay: res.sysConfig.IfAllAdmPay,  // 是否多选
						otherPayData: res.groupConfig.HBOPConfigPaymode[0].OPCharge || [],  // 其他付款方式
						IfSupplementOrd: res.sysConfig.IfSupplementOrd,  // 收费界面是否可以补录医嘱
						focusType: res.sysConfig.DefaultInputBox,  // 光标
						payType: res.groupConfig.HBOPConfigPaymode[0].OPCharge[0] ? res.groupConfig.HBOPConfigPaymode[0].OPCharge[0].paywID : '',
						otherPay: res.groupConfig.HBOPConfigPaymode[0].OPCharge[1] ? res.groupConfig.HBOPConfigPaymode[0].OPCharge[1].paywID : '',
						OPSearchData: res.sysConfig.OPSearchData,  // 时间,
						OPSearchFlag: res.sysConfig.OPSearchFlag,  // 时间
						invNum: res.invNum || '0',  // 发票数剩余
						groupConfig:res.groupConfig,
					}, () => {
						this.focusInput() // 获取光标
						let { otherPay, payType, OPSearchData, OPSearchFlag } = this.state
						if (otherPay === '7' || payType === '7') {  //合作记账单位
							this.setState({ hzDis: true })
						} else {
							this.setState({ hzDis: false })
						}
					});

					if (res.groupConfig.IfChargeFlag === 'Y') {
						if (res.groupConfig.IfInvNo === 'Y' && res.currentInvNoInfo.split('^')[0] !== '0') {
							message.error('该收费员无发票号', this.state.userData && this.state.userData.messageTime)
						}
					} else {
						message.error('无收费权限', this.state.userData && this.state.userData.messageTime)
						this.setState({
							disabledInput: true,  // 收费权限
						});
					}

					if (res.sysConfig.OPSearchFlag === 0) {  // 时间配置
						this.setState({
							StartDate: moment().subtract(res.sysConfig.OPSearchData, "days").format('YYYY-MM-DD'),  // //开始日期
						});
					}

					if (res.sysConfig.OPSearchFlag === 1) {  // 时间配置
						this.setState({
							StartDate: moment().subtract(2, "days").format('YYYY-MM-DD'),  // //开始日期
						});
					}
				}
			}
		});
	}

	// 合作单位
	unitsList = () => {
		let data = {
			params: [{
				"code": "",
				"desc": '',
			}]
		}
		$http.post('urlS', this, {
			code: "01040060",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {
					this.setState({
						unitsList: res.contractUnit, // 合作单位
					});
				}
			}
		});
	}

	// 费用类型table
	ordList1 = () => {
		let data = {
			params: [{
				"reactCode": ["PatientCharges"],
				"compontName": "PatientCharges",
				"type": "C"

			}]
		}
		$http.post('urlS', this, {
			code: "01040073",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {
					this.setState({
						columnsPatChar: res.result.C || {},  // 国际化Table2
						languageData: res.result.language || {},  // 国际化语言包
					}, () => {
						this.LanCNEN(this.state.languageCode)
						this.cloumData1(this.state.columnsPatChar)
					})
				}
			}
		});
	}

	LanCNEN = (code) => {
		let { languageData } = this.state
		this.setState({
			language: languageData[code]
		})
	}

	// 数据配置
	cloumData1(resC) {

		let { languageCode } = this.state
		for (var i = 0; i < resC.length; i++) {
			resC[i].key = i;
		}
		if (languageCode === "EN") {
			resC.map((item, i) => {
				item.title = item.enDescripts
			})
		}

		if (languageCode === "CN") {
			resC.map((item, i) => {
				item.title = item.descripts
			})
		}

		this.setState({
			columnsPatChar: resC, // 费用类型table
		});
	}


	// 费用类型table
	ordList2 = () => {
		let data = {
			params: [{
				"reactCode": ["OPChargeOrderList"],
				"compontName": "OPChargeOrderList",
				"type": "C"

			}]
		}
		$http.post('urlS', this, {
			code: "01040073",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {
					this.setState({
						columnsPatCharSome: res.result.C || {},  // 国际化Table2
					}, () => {
						this.cloumData2(this.state.columnsPatCharSome)
					})

				}
			}
		});
	}

	// 数据配置
	cloumData2(resC) {

		let { languageCode } = this.state
		for (var i = 0; i < resC.length; i++) {
			resC[i].key = i;
		}
		if (languageCode === "EN") {
			resC.map((item, i) => {
				item.title = item.enDescripts
			})
		}

		if (languageCode === "CN") {
			resC.map((item, i) => {
				item.title = item.descripts
			})
		}

		this.setState({
			columnsPatCharSome: resC, // 费用类型table
		}, () => {
			this.ordListAdd('0', 0, languageCode)    //render 自定义项目名称
		});
	}


	//render 自定义项目名称
	ordListAdd = (i, indexs) => {
		let { columnsPatCharSome, dataAdmReason } = this.state

		columnsPatCharSome.splice(1, i, {
			title: '项目名称',
			dataIndex: 'dataAdmReason',
			key: '99999',
			align: "center",
			width: 400,
			render(text, record, index) {
				return (

					<div style={{ textAlign: 'left' }} >
						<p>
							<span className='mL20' style={{ color: '#007AFF', textAlign: 'left' }}><span>{dataAdmReason[indexs] && dataAdmReason[indexs][index] ? <span dangerouslySetInnerHTML={{ __html: dataAdmReason[indexs][index].preMess }}></span> : ''}</span>{dataAdmReason[indexs] && dataAdmReason[indexs][index] ? <span dangerouslySetInnerHTML={{ __html: dataAdmReason[indexs][index].medDesc }}></span> : ''}</span>
						</p>
						<p>
							<span className='mL40' style={{ textAlign: 'left' }} >{dataAdmReason[indexs] && dataAdmReason[indexs][index] ? dataAdmReason[indexs][index].remarks : ''}</span>
						</p>
					</div>
				);
			}

		})

		this.setState({
			columnsPatCharSome, // 费用类型table
		});
	}

	//卡类型
	cardTypeList = () => {
		var data = {
			params: [{
				cardTypeFlag: 1,
			}]
		}

		$http.post('urlS', this, {
			code: "03030005",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {
					let cardDeffault = res.cardType.filter((item) => {
						return item.defaultFlag === 'Y';
					})
					this.setState({
						cardType: cardDeffault[0].id, // 默认卡
						cardTypeData: res.cardType,  // 用户数据
					}, () => {
						this.CardTypeChange(this.state.cardType)
					});
				}
			}
		});
	}

	// 读卡 --- 根据卡号取病人信息
	handleReadCard = (value, event) => {
		let { readModeI, readModeR, cardType } = this.state
		if (event.keyCode) {
			if (readModeI) {
				this.searchUser('cardNo'); // 重新调用查询接口
			}
			return false
		}
		if (readModeR) {
			this.readCard.ReadCard(cardType, "R", (json) => {
				let patNo = json && json.patInfo ? json.patInfo.patNo : ''
				this.setState({ patNo , cardNo: json.cardNo }, () => {
					//this.searchUser('cardNo'); // 重新调用查询接口
					if (patNo)
					{
							this.searchUser('patNo'); // 重新调用查询接口
					}else{
							this.searchUser('cardNo'); // 重新调用查询接口
					}
				},this.state.equipManagerObj?.readCardCode)
			})

		}

	}

	// // 回车读卡 --- 根据卡号取病人信息
	// handleReadCarddownE = (e, type) => {
	//     if (e.keyCode === 13) {

	//         this.searchUser('cardNo') // 读卡 --- 根据卡号取病人信息
	//     }
	// }

	// 读卡
	searchUser = (type) => {
		var data;
		let { cardType, cardNo, patNo, cardTypeData } = this.state
		if (!type) {   // 查询全部
			data = {
				params: [{
					"number": patNo || '', // 登记号/身份证号
					"cardTypeID": cardType,   //卡类型id
					"cardNo": cardNo,    //卡号
				}]
			}
		}

		if (type === 'patNo') {
			data = {
				params: [{
					"number": patNo || '', // 登记号/身份证号
					"cardTypeID": "",   //卡类型id
					"cardNo": "",    //卡号
				}]
			}

			if (patNo === '') {
				return false
			}
		}

		if (type === 'cardNo') {
			data = {
				params: [{
					"number": '', // 登记号/身份证号
					"cardTypeID": cardType || '',     //卡类型id
					"cardNo": cardNo, //卡号
				}]
			}

			if (cardNo === '') {
				return false
			}
			if (cardType === '') {
				message.error('请选择卡类型', this.state.userData && this.state.userData.messageTime)
				return false
			}


			let cardTypeFilter = cardTypeData.filter(function (item) {
				return item.id == cardType;
			})

			let zeroLength = cardTypeFilter[0].cardLength

			if (zeroLength && zeroLength != '' && parseFloat(zeroLength) != 0) {
				this.setState({
					cardNo: ArraySome.addPreZero(cardNo, zeroLength)
				})
				data = {
					params: [{
						"number": '', // 登记号/身份证号
						"cardTypeID": cardType || '',     //卡类型id
						"cardNo": ArraySome.addPreZero(cardNo, zeroLength) || '', //卡号
					}]
				}
			}
		}

		// if (patNo === '' && cardNo === '') {
		//     this.medicalInformation()
		//     return false
		// }

		$http.post('urlS', this, {
			code: "03040004",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {

					this.setState({
						userInfo: res.data || [],  // 用户数据
						settlementTypeData: res.data.admReason || [],  // 结算类型
						patNo: res.data.patNo || '',  // ID
						selectedRowKeys2: [],
						dataPatChar: [],
						admID: '',
					}, () => {
						this.medicalInformation() // 就诊信息
					});

				} else {
					this.clearnFile()  // 清空
				}
			}
		});
	}

	// 就诊信息
	medicalInformation = (e) => {
		let { selectedRowKeys2 } = this.state
		var data = {
			params: [{
				hospID: JSON.parse(window.sessionStorage.userData).hospID || '', //医院id
				patID: this.state.userInfo.patID || '',  //病人id
				outFlag: '', //预留参数
				admID: this.state.admID || '', //就诊id
				"findCondition": this.state.findCondition || '',
				"stDate": this.state.StartDate || '',  //开始日期
				"endDate": this.state.EndDate || '',    //结束日期
			}]
		}

		$http.post('urlS', this, {
			code: "05210003",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {
					this.setState({
						selectedRowKeys2: selectedRowKeys2 || [], //默认选中
						dataPatChar: res.admInfo || [], // // 挂号table数据
						dataAdmReason: [],
						isListCheckload: [], // //是否加载过
						selecteId: '', //
						orderAdmReason: [
							{ ordReasonID: '0', ordReasonDesc: "费用类型" } // 默认费用类型
						], // tab费用类型
					}, () => {
						if (Util.isEmpty(this.state.dataPatChar)) {
							this.setState({ allPrice: '0.00', allPatPrice: '0.00' })
						}
						//单选
						if (this.state.IfAllAdmPay !== 'Y' && this.state.dataPatChar && this.state.dataPatChar.length > 0) {
							this.costType(this.state.dataPatChar[0])
						}
						//多选
						if (this.state.IfAllAdmPay === 'Y' && this.state.dataPatChar && this.state.dataPatChar.length > 0) {
							if (this.state.findCondition === 'Y') {
								this.setState({
									selectedRowKeys2: [1, 2]
								})
								let key = []
								let { dataPatChar } = this.state
								dataPatChar.map((item, i) => {
									let index = i + 1
									key.push(index)
								})


								this.rowSelectionOnChange(key, dataPatChar)
							}
						}
					});

				}
			}
		});
	}
	modalShowHis = () => {
		this.setState({
			modalShowHis: true
		})
	}
	// 回车查询登记号
	patNodownE = (e, type) => {
		if (e.keyCode === 13) {
			this.searchUser(type)
		}
	}

	// 单击行
	costType = (record) => {
		if (this.state.IfAllAdmPay === 'Y') {
			return false
		}
		var admIdStr = []
		admIdStr.push(record.admID)
		this.setState({
			admIdStr: admIdStr, //费用类型  数组
			selecteId: record.admID,
			admID: record.admID,
		}, () => {
			this.costTypeHttp('', '0', '', '') // 收费类型接口
		});


	}

	// 收费类型接口
	costTypeHttp = (ordReasonID, i, ordReasonChange, changeIS) => {
		// ordReasonChange 特殊参数 切换不回到tabs首项
		let { PayReasonDr, payrecordstr } = this.state
		if (!ordReasonChange || ordReasonChange === '') {
			payrecordstr = []
		}
		if (changeIS != 'Y') {
			PayReasonDr = ''
		}
		var data = {
			params: [{
				// hospId: JSON.parse(window.sessionStorage.userData).hospID || '', //医院id
				ordReasonID: ordReasonID || '', // tab子项切换
				payReasonID: PayReasonDr || '', // 结算类型
				ordIDArr: payrecordstr  // 已经勾选的部分
			}],
			admIDArr: this.state.admIdStr //费用类型  数组
		}



		$http.post('urlS', this, {
			code: "05210004",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {
					if (res.msgAlert && res.msgAlert != '') {
						message.error(res.msgAlert, this.state.userData && this.state.userData.messageTime)
					}

					if (res.orderInfo && res.orderInfo.length === 0) {
						this.setState({
							dataAdmReason: [], // 费用类型table数据
							orderAdmReason: [
								{ ordReasonID: '0', ordReasonDesc: "费用类型" } // 默认费用类型
							], // tab费用类型
						})
					}

					let { dataAdmReason, selectedRowKeys, isListCheckload } = this.state


					if (res.orderAdmReason && dataAdmReason.length < res.orderAdmReason.length) {
						res.orderAdmReason.map(() => {
							dataAdmReason.push([])
							selectedRowKeys.push([])
						})
					}

					// if (!isListCheckload.includes(i)) {
					// 筛选数组 默认选择
					let selectedRowKeysArrfilter = res.orderInfo.filter((item) => {
						return item.ordCheck === 'Y';
					})
					let selectedRowKeysArr = selectedRowKeysArrfilter.map((item) => {
						return item.key
					})


					selectedRowKeys[i] = selectedRowKeysArr // 默认选择
					dataAdmReason[i] = res.orderInfo  // tab费用类型数据
					isListCheckload.push(i) //isListCheckload 是否加载过

					// }




					this.allPriceAdd(selectedRowKeysArrfilter)  //算价格

					this.setState({
						activeKey: i || '0',
						tabKey: i || 0,
						orderAdmReason: res.orderAdmReason && res.orderAdmReason.length > 0 ? res.orderAdmReason : this.state.orderAdmReason,  // tab费用类型
						dataAdmReason: dataAdmReason || [],  // tab费用类型数据
						noJoinChargeOrderRowidStr: res.noJoinChargeOrderRowidStr || [],  // tab费用类型数据
						PayReasonDr: ordReasonID === '' ? res.orderAdmReason[0].ordReasonID : ordReasonID, // 结算类型
						selectedRowKeys: selectedRowKeys || [], //默认选中
						isListCheckload: isListCheckload, //是否加载过
						oldSelectedRowKeysArr: selectedRowKeysArr || [],// 上一个选择数据
					}, () => {
						this.ordListAdd('1', i)    //render 自定义项目名称
						if (ordReasonChange) {
							this.setState({
								PayReasonDr: ordReasonChange // 手动下拉框
							})
						}


					});
				}
			}
		});
	}

	// 查询条件 --- 类型·
	cardType = (e) => {
		this.setState({ cardType: e }, () => {
			this.CardTypeChange(e)
		});
		var { cardTypeData } = this.state;
		for (var i = 0; i < cardTypeData.length; i++) {
			if (e == cardTypeData[i].id) {
				this.setState({
					equipManagerObj: cardTypeData[i].equipManagerObj
				})
			}
		}
	}

	// Card
	CardTypeChange = (e) => {
		if (!e) {
			return false
		}
		let { cardTypeData } = this.state
		let readMode = cardTypeData.filter((item, i) => {
			return item.id == e;
		})

		switch (readMode[0] && readMode[0].readMode) {
			// 只可input
			case 'I':
				this.setState({
					readModeI: true,
					readModeR: false,
					cardNo: "",

				})
				break;
			// 只可读卡
			case 'R':
				this.setState({
					readModeR: true,
					readModeI: false,
					cardNo: "",
				})
				break;
			// 皆可
			default:
				this.setState({
					readModeI: true,
					readModeR: true,
					cardNo: "",
				})
				break;
		}

	}

	// 查询条件 --- 结算类型
	PayReasonDr = (e) => {
		let itemselect = this.state.settlementTypeData.filter((item) => {
			return item.id == e;
		})
		this.setState({ PayReasonDr: e, OPInsuType: itemselect[0] ? itemselect[0].OPInsuType : '' ,reasonCode:itemselect[0].code}, () => {
			let { tabKey, orderAdmReason } = this.state

			let ordReasonID = orderAdmReason[tabKey] ? orderAdmReason[tabKey].ordReasonID : ''

			this.costTypeHttp(ordReasonID, tabKey, e, 'Y')

		});




	}




	// 查询条件 --- 卡号
	cardNo = (e) => {
		let { readModeI } = this.state
		if (!readModeI) {
			return false
		}
		this.setState({ cardNo: e.target.value });
	}

	// 查询条件 --- 登记号
	patNo = (e) => {
		this.setState({ patNo: e.target.value });
	}

	// 其他支付方式
	otherPay = (e) => {

		this.setState({ otherPay: e }, () => {
			let { otherPay, payType } = this.state
			setTimeout(() => {
				this.myRef4.current.focus();
			}, 300)
			if (otherPay === '7' || payType === '7') {  //合作记账单位
				this.setState({ hzDis: true })
			} else {
				this.setState({ hzDis: false })
			}
		});
	}

	// 支付方式
	payType = (e) => {
		this.setState({ payType: e }, () => {
			let { otherPay, payType } = this.state
			setTimeout(() => {
				this.myRef2.current.focus();
			}, 300)

			if (otherPay === '7' || payType === '7') {  //合作记账单位
				this.setState({ hzDis: true })
			} else {
				this.setState({ hzDis: false })
			}
		});
	}

	// 合作单位
	unitsListVal = (e) => {
		this.setState({ unitsListVal: e }, () => {
			setTimeout(() => {
				this.myRef6.current.focus();
			}, 300)
		});
	}

	//收费状态
	findCondition = (e) => {
		this.setState({ findCondition: e });
	}





	// 弹框关闭
	handleCancel = () => {
		let { payButtonNum, chargeRecodeId } = this.state

		this.setState({
			modalShow: false,
			modalShowPay: false, //  收银弹框的显示
			modalShowHis: false, //  就诊记录
		}, () => {
			this.setState({
				payButtonNum: 1, // 收银步骤
			})
		});


		if (payButtonNum === 3) {

			var data = {
				params: [{
					"recordIDinfo": chargeRecodeId, //付款记录串
					"hisTradeNum": "",   //his交易流水
					"userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
					"ip": React.$getSessionData('ipConfig')?.ipv4 || '', //ip
				}]
			}


			$http.post('urlADS', this, {
				code: "05210010",
				data: data,
				success: function (res) {
					let errorCode = res.errorCode;
					if (errorCode === '0') {

					}
				}
			});

		}

	}

	// 历史记录
	historyModal = () => {

		// if (JSON.stringify(this.state.userInfo) === "{}") {
		//     message.warning('请先查询患者')
		//     return false
		// }

		this.setState({
			modalShow: true,
		});
	}

	//tab 子切换
	TabChange = (key) => {
		let ordReasonID = this.state.orderAdmReason[key].ordReasonID

		this.setState({
			tabKey: key, // 当前的tab页面key
			oldSelectedRowKeysArr: [],// 上一个选择数据
		}, () => {
			this.costTypeHttp(ordReasonID, key, '', '')
		})

	}
	onCardChange = (e) => {

		this.setState({ cardNumber: e.target.value });
	}
	onqrCodeChange = (e) => {
		this.setState({ qrCode: e.target.value });
	}
	YBInputSure = () => {

		this.setState({ cardShow: false,INSUICDCode: '',    // 医保诊断code
			INSUICDDesc: '',    // 医保诊断描述
			xnhBCTYPE:'',
			comepnCodeList: [],
			comepnCode: '', }, () => {
			this.syLoading("请等待");
		});
	}
	syLoading = async (title) => {

		let { PayReasonDr } = this.state
		let openModal = Modal.info({
			title: title,
			content: <Spin size="large" />,
			okText: "",
			onOk() { },
		});
		try {
			let itemselect = this.state.settlementTypeData.filter((item) => {
				return item.id == PayReasonDr;
			})

			/**
			 * @ByYQL: 读医保卡或医保电子凭证
			 * Create 2021-12-26
			 */
			/**
			 * @ByYQL: 统一基线版前端调用DLL封装
			 * iShowForm ： 是否弹窗 0 不弹  1 弹
			 * iCardType ： 01：电子凭证   02：身份证   03：社保卡
			 * operatorId ：收款员工号
			 * operatorName : 	收款员姓名
			 * officeId ：科室id
			 * officeName ： 科室名称
			 * patID : 病人id
			 * Create 2022-1-24
			 */
			var certType=this.state.certType
			var certNo=this.state.certNo
			//----------------------------------------
			let dllInputdata = {
				"iShowForm": 0,
				"iCardType": certType,
				"operatorId": JSON.parse(window.sessionStorage.userData).userCode,
				"operatorName": JSON.parse(window.sessionStorage.userData).userName,
				"officeId": JSON.parse(window.sessionStorage.userData).locID,
				"officeName": JSON.parse(window.sessionStorage.userData).locDesc,
				"patID": this.state.userInfo.patID || ''
			}
			// if( certType =="03" || certType =="01"){
				var retStr= await INSUYBUtil.ReadInsuCard(dllInputdata);
				let resObj = JSON.parse(retStr);
				console.log( 'retStr',retStr );
				if(resObj.errorCode!="0"){
					message.warn(resObj.errorMessage);
					openModal.destroy();
					return
				}
				// cardSN=resObj.result.cardsn
				certNo = resObj.result.cardInfo
			// }
			//----------------------------------------
			// // var cardSN=""
			// let dllData = {"admID":this.state.admID,"reasonCode":this.state.PayReasonDr,"MdtrtCertType":this.state.certType,"bussType":"M1"}
			// 	var retStr= await INSUYBUtil.ReadInsuCard(JSON.stringify(dllData));
			// 	let resObj = JSON.parse(retStr);
			// 	console.log( 'retStr',retStr );
			// 	if(resObj.errorCode!="0"){
			// 		message.warn(resObj.errorMessage);
			// 		openModal.destroy();
			// 		return
			// 	}
			// 	// cardSN=resObj.result.cardsn
			// 	certNo = resObj.result.cardInfo
			//----------------------------------------

			this.setState({
				certType,
				certNo,
				// cardSN
			})
			let data = {
				"params": [{
					"userID": JSON.parse(window.sessionStorage.userData).userID,
					"patID": this.state.userInfo.patID || '',  //病人id
					"reasonCode": itemselect[0].code,
					"patName": this.state.userInfo.patName || '',  //病人姓名
					"certNo":this.state.certNo,
					"certType":this.state.certType,
					"locID": JSON.parse(window.sessionStorage.userData).locID,
					"hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
					"groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
					"ip": React.$getSessionData('ipConfig')?.ipv4 || '',
					"mac":React.$getSessionData('ipConfig')?.mac || '',
					"insuAdmvs":this.state.insuAdmdvs
				}]
			}


			let hisdataobj = await INSUYBUtil.GoTOHISHttp(data, "05020001");    //调用his接口
			if (hisdataobj.errorCode != '0') {
				//message.warn(hisdataobj.errorMessage);
				Keup.ModalMessage(15, this, hisdataobj.errorMessage, '自动关闭', 'destroy', '确定', 'error')
				openModal.destroy();
			}else{
				let errorCode = hisdataobj.errorCode;
				if (errorCode === '0') {
					let divdata = hisdataobj.result.patYBData ? hisdataobj.result.patYBData : [];
					let insuTypeList=hisdataobj.result.insuTypeData;
					let insuMedTypeList=hisdataobj.result.insuMedTypeData;
					let diseCodeList=hisdataobj.result.diseCodeData;
					let birctrlTypeList=hisdataobj.result.birctrlTypeData;
					let insuMdtrtGrpTypeList = hisdataobj.result?.insuMdtrtGrpTypeData;
					let comepnCodeList=[];
					this.setState({
						comepnCodeList,
						divdata,
						insuInfoShow: true,
						readCarddata:divdata,
						insuTypeList,
						insuMedTypeList,
						diseCodeList,
						birctrlTypeList,
						insuMdtrtGrpTypeList
					})
				}
			}
			openModal.destroy();
		}catch (error) {
			message.warning("异常")
			openModal.destroy();
			console.log(error);
		}
	}
	//收银
	payButton = async () => {
		this.setState({ insuReadFlag: "N", insuPayID: "", personalData: "", password: "", chargeRecodeId: "" });
		// 自费 ,医保，身份证
		INSUYBUtil.isReadFlag(this.state.admIdStr, this.state.PayReasonDr, "", "").then(async (resData) => {

			if (resData.insuReadFlag == "Y") {
				this.setState({ cardShow: true, cardNumber: "", qrCode: "", insuReadFlag: resData.insuReadFlag ,insuAdmdvsList:resData.admdvs});
				//需要医保结算弹出医保卡号输入界面
				/*if (this.state.PayReasonDr === "8") { // 城乡医保走身份证号姓名弹窗
					this.setState({ nameAndIDNumberVisible: true, patName: undefined, patCard: undefined, insuReadFlag: resData.insuReadFlag });
				} else {
					this.setState({ cardShow: true, cardNumber: "", qrCode: "", insuReadFlag: resData.insuReadFlag });
					//职工医保
					this.setState({
						cardShow: false, INSUICDCode: '',    // 医保诊断code
						INSUICDDesc: '',    // 医保诊断描述
						comepnCodeList: [],
						comepnCode: '',
					}, () => {
						this.syLoading("请等待");
					});
				}*/
				this.setState({
					cardShow: true,
					INSUICDCode: '',    // 医保诊断code
					INSUICDDesc: '',    // 医保诊断描述
					comepnCodeList: [],
					comepnCode: '',
				});
			}
			else {
				this.loading();
			}
		});
	}
	// 关闭窗口并且 调收银方法
	closeModal = () => {
		let { selectedRowKeys, tabKey, selectedRowKeys2, IfAllAdmPay, personalData, readCarddata } = this.state
		this.setState({
			personalData: readCarddata,
			password: '',
			insuInfoShow: false
		})
		if (IfAllAdmPay === 'Y' && selectedRowKeys2.length < 1) {
			// message.error('请选择至少一项')
			return false;
		}
		if (selectedRowKeys[tabKey] && selectedRowKeys[tabKey].length < 1) {
			// message.error('请选择至少一项')
			return false;

		} else {
			let { PayReasonDr } = this.state
			let itemselect = this.state.settlementTypeData.filter((item) => {
				return item.id == PayReasonDr;
			})
			this.loading() //预结算 ;
		}
	}
	//收银确认按钮
	openPayModal = async (openModal) => {
		let { payButtonNum, otherPay, otherPayMoney, cashInCashVal, moneyData, otherPayData, tabKey, PayReasonDr, orderAdmReason } = this.state
		///判断是否进入医保预结算

		if (this.state.insuReadFlag == "Y") {
			//进入医保预结算
			let itemselect = this.state.settlementTypeData.filter((item) => {
				return item.id == PayReasonDr;
			})

			let insupaydata = {
				params: [{
					"ybPayType": "PRE",  //医保预结算
					"admID": this.state.admID || '', // 结算类型
					"userID": JSON.parse(window.sessionStorage.userData).userID || '',
					"ordAdmReasonID": orderAdmReason[tabKey].ordReasonID || '',
					"admReasonID": PayReasonDr || '', // 结算类型
					"paytype": "O",
					"locID": JSON.parse(window.sessionStorage.userData).locID,
					"hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
					"groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
					"ip": React.$getSessionData('ipConfig')?.ipv4 || '',
					"recordID": this.state.chargeRecodeId, //交款记录id
					"readCard": this.state.personalData,
					"patID": this.state.userInfo.patID || '',  //病人id
					"reasonCode": itemselect[0].code || '',  ///费别代码
					"diseCode":this.state.diseCode,
					"diseDesc":this.state.diseDesc,
					"birctrlType":this.state.birctrlType,
					"birctrlDate":this.state.birctrlDate,
					"userAccFlag":this.state.userAccFlag,
					"insuType":this.state.insuType,
					"certType":this.state.certType,
					"certNo":this.state.certNo,
					"insuMedType":this.state.insuMedType,
					"insuMdtrtGrpType":this.state.insuMdtrtGrpType,
					"traumaFlag":this.state.traumaFlag,
					"thirdFlag":this.state.thirdFlag,
					"mac":React.$getSessionData('ipConfig')?.mac || '',
					"refundFlag": "N"
				}],
			}

			let res = await INSUYBUtil.GoTOHISHttp(insupaydata, "05020002");    //调用his接口
			if (res.errorCode != '0') {
				this.RollBACKOPCharge()
				//message.warn(res.errorMessage);
				Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
				openModal.destroy() //关闭等待界面
				return;
			}else{
				var insuPayID=res.result.insuPayID
				this.setState({ insuPayID: res.insuPayID });
			}
			/*let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuOPPay", insupaydata);
			let res = JSON.parse(YBPatDivdata);
			if (res.errorCode == '0') {
				this.setState({ insuPayID: res.insuPayID });
			}
			else {
				this.RollBACKOPCharge()
				message.warn(res.errorMessage);
				return;
			}*/

		}
		openModal.destroy() //关闭等待界面
		this.setState({
			modalShowPay: true, //  收银弹框的显示
			modalPayTitle: '收银', //  收银弹框的标题
			modalShowPayWidth: '900px',
			loadfalse: 'true'  // 允许下一步
		});

	}
	//收银弹框的标题变化
	changeMoadlTitle = (num) => {
		switch (num) {
			case 1:
				this.setState({
					modalPayTitle: '读取病人医保卡', //  收银弹框的标题
					modalShowPayWidth: '700px'
				});
				break;

			case 2:
				this.setState({
					modalPayTitle: '正在进行预结算,请稍等...', //  收银弹框的标题
					modalShowPayWidth: '400px',
					loadfalse: 'false',  // 允许下一步
				}, () => {
					var interval = setInterval(() => {
						let { personalData, PayReasonDr } = this.state
						let itemselect = this.state.settlementTypeData.filter((item) => {
							return item.id == PayReasonDr;
						})
						if (itemselect[0].OPInsuType === 'Y') {
							if (personalData && personalData != '') {
								clearInterval(interval);
								console.log(1)
								this.loading() //预结算
							}
						} else {
							clearInterval(interval);
							this.loading() //预结算
						}
					}, 100);
				});
				break;
			case 3:
				this.setState({
					modalPayTitle: '收银', //  收银弹框的标题
					modalShowPayWidth: '900px',
					loadfalse: 'true'  // 允许下一步
				}, () => {

				});

				break;
			case 4:
				this.setState({
					modalPayTitle: '扫描付款码', //  收银弹框的标题
					modalShowPayWidth: '600px'
				}, () => {
					this.childfPatPay.chargingConfir() //确认收费
				});

				break;

			default:
				this.handleCancel() // 关闭
				break;
		}

	}

	MakeMoney(res) {
		this.clearnFile() //清空
		this.handleCancel()  // 关闭弹框
		// this.medicalInformation() // 就诊信息
		let messageTime = this.state.userData && this.state.userData.messageTime ? this.state.userData.messageTime : 3;
		Keup.ModalMessage(messageTime, this, '支付成功！', '自动关闭', 'destroy', '确定', 'success')
		this.initJuris() // 权限
		this.setState({
			compleRecordIDinfo: res.compleRecordIDinfo,
			invIDinfo: res.invIDinfo
		}, () => {
			if (JSON.parse(window.sessionStorage.userData).hospCode=='H19'){
				for(var i=0;i<3;i++){
					this.print()  // 打印
				}
			}else{
				for(var i=0;i<2;i++){
					this.print()  // 打印
				}
			}
			// this.handlePrintChargeVoucher()//打印收费凭证
		})
	}

	handlePrintChargeVoucher() {
        var data = {
            params: [{
                recordID: this.state.compleRecordIDinfo,
            }]
        }
        $http.post('urlADS', this, {
            code: "05210076",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    let dataArr = res.result
                    dataArr.map((item, i) => {
                        $loadTemplate(item.template, item.printStr);
					})
					this.focusInput() // 获取光标
                }
            }
        });
    }

	//清空
	clearnFile = () => {
		this.setState({
			dataAdmReason: [], // 费用类型table数据
			orderAdmReason: [
				{ ordReasonID: '0', ordReasonDesc: "费用类型" } // 默认费用类型
			], // tab费用类型
			userInfo: {}, // 用户数据
			cardNo: '',
			patNo: '',
			// invoice: '',
			dataPatChar: [],  // 挂号table数据
			settlementTypeData: [], // 结算类型
			payButtonNum: 1, // 收银步骤
			allPrice: '0.00', // 费用总额
			allPatPrice: '0.00', // 病人应付金额
			PayReasonDr: '', // 结算类型
			reasonCode:"",
			payrecordstr: [], // 付款记录表id串
			modalPayTitle: '请输入社保卡密码', // 收银弹框的标题
			moneyData: {}, //金额对象
			// otherPay: '', //其他支付方式
			PayDis: false,
			otherPayDis: false, //其他支付方式不可选
			otherPayMoney: '0.00', // 其他支付金额
			cashInCashVal: '', // 实收现金
			zeroPay: '0.00', // 找零
			accountPayWayId: '', // 院内账户支付方式id
			payWayCashId: '', // 现金支付方式id
			otherPaywayId: '', // 其他付款方式id
			loadfalse: 'true', // 允许下一步
			isListCheckload: [], // //是否加载过
			selectedRowKeys: [], //  清除选中
			selectedRowKeys2: [], //  清除选中
			admID: '', // 就诊id
			OPInsuType: '', //
			selecteId: '', //
			oldSelectedRowKeysArr: [],// 上一个选择数据
			activeKey: '0', //tab当前key
			findCondition: 'Y',
			// StartDate: undefined,  // //开始日期
			// EndDate: undefined,  // //结束日期
			// payType: '', //付款方式
			maypayData: [],
			hzDis: false,
			readModeI: true,
			readModeR: true,
			qrCode: "",
			cardNumber: "",
			cardShow: false,
			insuReadFlag: "N",
			insuPayID: "",
			chargeRecodeId: ""
		});

	}

	//预结算
	loading = () => {
		let openModal = Modal.info({
			title: "正在进行预结算,请稍等...",
			content: <Spin size="large" />,
			okText: "",
			onOk() { },
		});
		let { payrecordstr, admIdStr, PayReasonDr, tabKey, orderAdmReason, allPatPrice, noJoinChargeOrderRowidStr, password, personalData } = this.state
		let totalArr = []
		this.state.dataAdmReason[tabKey] && this.state.dataAdmReason[tabKey].map((item, i) => {
			totalArr.push(item.ordID)
		})
		let len = totalArr.length
		for (let i = len - 1; i >= 0; i--) {
			let val = totalArr[i]
			if (payrecordstr.indexOf(val) > -1) {
				totalArr.splice(i, 1)
			}
		}
		let res = totalArr.concat(noJoinChargeOrderRowidStr)
		let itemselect = this.state.settlementTypeData.filter((item) => {
			return item.id == PayReasonDr;
		})
		var data = {
			params: [{
				"admIDinfo": admIdStr || '', // 结算类型
				"userID": JSON.parse(window.sessionStorage.userData).userID || '',
				"unchargeordIDinfo": res || "",
				"chargeordIDinfo": "",
				"ordAdmReasonID": orderAdmReason[tabKey].ordReasonID || '',
				"payadmReasonID": PayReasonDr || '', // 结算类型
				"paytype": "O",
				"patpaysum": allPatPrice,
				"sflag": "0",
				"ip": React.$getSessionData('ipConfig')?.ipv4 || ''
			}]
		}
		$http.post('urlADS', this, {
			code: "05210006",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {
					this.setState({
						chargeRecodeId: res.recordIDinfo, //交款记录id
						loadfalse: 'true'  // 允许下一步
					}, () => {
						this.openPayModal(openModal) //进入支付方式界面
					})
				} else {
					openModal.destroy(); // 弹框等待提示
				}
			}
		});

	}
	//门诊收费预结算回滚(门诊收费异常撤消)
	RollBACKOPCharge = async () => {
		let { payButtonNum, chargeRecodeId } = this.state
		///判断付款记录是否可以撤消
		if (chargeRecodeId != "") {
			///判断付款记录是否是医保记录
			var paramsdata = {
				params: [{
					"recordinvID": chargeRecodeId, //付款记录串
					"invtype": "PAY",   //his交易流水
					"userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
					"ip": React.$getSessionData('ipConfig')?.ipv4 || '', //ip
					"hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院
				}]
			}
			let hisdataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210047");    //调用his接口
			if (hisdataobj.errorCode != '0') {
				message.warn(res.errorMessage);
				return
			}
			var insuPayID = hisdataobj.insuPayIDinfo
			if (insuPayID != "") {
				///医保退费
				let dllInputdata = {
					"params": [{
						"userID": JSON.parse(window.sessionStorage.userData).userID,
						"insuPayID": insuPayID,
						"hospID": JSON.parse(window.sessionStorage.userData).hospID,
						"patID": this.state.userInfo.patID || '',  //病人id
					}],
					"code": "05210046"
				}
				let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuOPRefund", dllInputdata);
				let res = JSON.parse(YBPatDivdata);
				if (res.errorCode != '0') {
					message.warn(res.errorMessage);
					return
				}
			}
			///his预结算回滚(门诊收费异常撤消)
			var data = {
				params: [{
					"recordIDinfo": chargeRecodeId, //付款记录串
					"hisTradeNum": "",   //his交易流水
					"userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
					"ip": React.$getSessionData('ipConfig')?.ipv4 || '', //ip
				}]
			}
			$http.post('urlADS', this, {
				code: "05210010",
				data: data,
				success: function (res) {
					let errorCode = res.errorCode;
					if (errorCode === '0') {
						this.handleCancel()
					}
					else {
						message.warn(res.errorMessage);
					}
				}
			});

		}

	}

	/**
	 * @ByYQL: 医保结算前进行卡验密
	 * 如需取消卡验密流程，则将调用payButtonVerfiyOk的地方直接替换成payButtonOk
	 * Create 2021-12-26
	 */
	payButtonVerfiyOk = async () => {
		//----------------------------------------
		var certType=this.state.certType
		if( certType =="03"){
			message.loading('验密进行中,请提醒患者输入密码...')
			var retStr= await INSUYBUtil.VerfiyPin("{}");
			let resObj = JSON.parse(retStr);
			if(resObj.errorCode!="0"){
				message.warn(resObj.errorMessage);
				return
			}
			this.payButtonOk()
		}else{this.payButtonOk()}
		//----------------------------------------
		// let dllData = {"admID":this.state.admID,"reasonCode":this.state.PayReasonDr,"MdtrtCertType":this.state.certType,"bussType":"M5"}
		// var retStr= await INSUYBUtil.ReadInsuCard(JSON.stringify(dllData));
		// let resObj = JSON.parse(retStr);
		// if(resObj.errorCode!="0"){
		// 	message.warn(resObj.errorMessage);
		// 	return
		// }
		// this.payButtonOk()
	}

	//收银确认按钮
	payButtonOk = async () => {
		// debugger;
		let payopenModal = Modal.info({
            title: "正在HIS结算，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
		let { PayReasonDr, tabKey, orderAdmReason, insuAdmID, personalData } = this.state
		if (!this.childfPatPay.chargingConfirError()) {     //收费确认前验证
			return false
		}
		if (this.state.insuPayID !== "") {
			let itemselect = this.state.settlementTypeData.filter((item) => {
				return item.id == PayReasonDr;
			})

			//医保确认结算
			let insupaydata = {
				params: [{
					"ybPayType": "PAY",  //医保预结算
					"admID": this.state.admID || '', // 结算类型
					"userID": JSON.parse(window.sessionStorage.userData).userID || '',
					"ordAdmReasonID": orderAdmReason[tabKey].ordReasonID || '',
					"payadmReasonID": PayReasonDr || '', // 结算类型
					"paytype": "O",
					"locID": JSON.parse(window.sessionStorage.userData).locID,
					"hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
					"groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
					"ip": React.$getSessionData('ipConfig')?.ipv4 || '',
					"mac": React.$getSessionData('ipConfig')?.mac || '',
					"recordID": this.state.chargeRecodeId, //交款记录id
					"insuPayID": this.state.insuPayID,
					"patID": this.state.userInfo.patID || '',  //病人id
					"refundFlag": "N",
					"certNo":this.state.certNo,
					"certType":this.state.certType,
					"userAccFlag":this.state.userAccFlag,
				}],
			}
			let res = await INSUYBUtil.GoTOHISHttp(insupaydata, "05020011");    //调用his接口
			if (res.errorCode == '0') {
				this.setState({
					insuPayID: "" //在本次操作中医保已结算成功就不能再调用医保结算了
				})
				this.sureOk();
			}
			else {
				this.RollBACKOPCharge()
				this.handleCancel()
				payopenModal.destroy() //关闭等待界面
				Keup.ModalMessage(10, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
				return;
			}

		} else {
			this.sureOk();
		}
		setTimeout(() => {
            payopenModal.destroy() //关闭等待界面
         }, 1000);
		// this.sureOk();
	}
	sureOk = () => {


		this.childfPatPay.chargingConfir() //确认收费
		// this.setState({
		//     modalPayTitle: '扫描付款码', //  收银弹框的标题
		//     modalShowPayWidth: '600px'
		// }, () => {
		//     this.childfPatPay.chargingConfir() //确认收费
		// });
	}
	// 打印
	print = () => {

		var data = {
			params: [{
				"hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
				"groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
				"printType": "O",
				"printTemplateCode": "",
				"recordIDStr": this.state.compleRecordIDinfo || '',
				"invIDStr": this.state.invIDinfo || '',

			}]
		}


		$http.post('urlADS', this, {
			code: "05100153",
			data: data,
			success: function (res) {
				let errorCode = res.errorCode;
				if (errorCode === '0') {
					let dataArr = res.data
					let template = res.template
					dataArr.map((item, i) => {
						$loadTemplate(template[i], item.toString());
					})
					setTimeout(()=>{
						this.focusInput() // 获取光标
					},1000)
				}
			}
		});
	}

	// 实收现金
	cashInCashUp = (e) => {
		if (e.keyCode === 13) {
			this.cashInCash(e) // 实收现金
		}
	}


	// 其他支付方式金额
	otherPayMoney = (e) => {
		this.setState({ otherPayMoney: Keup.MoneyReplace(e.target.value) });
		if (Keup.MoneyReplace(e.target.value) === '') {
			return false
		}
		let { moneyData } = this.state
		if (parseFloat(Keup.MoneyReplace(this.state.cashInCashVal)) + parseFloat(Keup.MoneyReplace(e.target.value)) > parseFloat(this.state.moneyData.lastPayAmt)) {
			this.setState({
				zeroPay: parseFloat(parseFloat(Keup.MoneyReplace(this.state.cashInCashVal)) + parseFloat(Keup.MoneyReplace(e.target.value)) - parseFloat(this.state.moneyData.lastPayAmt)).toFixed(2)// 找零
			}, () => {
				this.sumMoney()
			})

		} else {
			this.setState({
				zeroPay: '0.00', // 找零
			}, () => {
				this.sumMoney()
			})
		}


	}

	// 实收现金
	cashInCash = (e) => {
		let val = e.target.value
		let { moneyData } = this.state


		this.setState({
			cashInCashVal: Keup.MoneyReplace(val) // 金额过滤
		})

		if (Keup.MoneyReplace(val) === '') {
			return false
		}


		if (parseFloat(Keup.MoneyReplace(val)) > parseFloat(moneyData.lastPayAmt)) {
			this.setState({
				otherPayDis: true, // 其他支付不可选
				// otherPay: '', // 其他支付方式
				otherPayMoney: '0.00', // 其他支付金额
				zeroPay: parseFloat(parseFloat(Keup.MoneyReplace(val)) - parseFloat(moneyData.lastPayAmt)).toFixed(2)// 找零
			}, () => {
				this.sumMoney()
			})

		} else {
			this.setState({
				otherPayDis: false, // 其他支付不可选
				// otherPay: '', // 其他支付方式
				otherPayMoney: parseFloat(parseFloat(moneyData.lastPayAmt) - parseFloat(moneyData.payingAccountAmt) - parseFloat(Keup.MoneyReplace(val))).toFixed(2), // 其他支付金额
				zeroPay: '0.00', // 找零
			}, () => {
				this.sumMoney()
			})
		}

	}

	//计算
	sumMoney = () => {
		let { moneyData, payingAccountAmt } = this.state

		moneyData.payingAccountAmt = payingAccountAmt

		moneyData.payingAccountAmt = parseFloat(parseFloat(moneyData.payingAccountAmt) - parseFloat(this.state.otherPayMoney) - parseFloat(this.state.cashInCashVal)).toFixed(2)

		if (parseFloat(moneyData.payingAccountAmt) < 0) {
			moneyData.payingAccountAmt = '0.00'
		}

		this.setState({
			moneyData: moneyData
		})
	}


	// table行样式
	setRowClassName = (record) => {
		return record.ordSelect === 'N' ? 'disabledTable' : '';
	}

	// table行样式
	setRowClassNameSelect = (record) => {
		return record.admID === this.state.selecteId ? 'redTable' : '';
	}


	// 时间
	onChangeTime = (date, dateString) => {
		this.setState({
			StartDate: dateString[0],    //开始日期
			EndDate: dateString[1],  //结束日期
		})

	}

	startChange(date) {
		this.setState({
			StartDate: date,
		})
	}

	endChange(date) {
		this.setState({
			EndDate: date,
		})
	}

	password(e) {
		this.setState({
			password: e.target.value,
		})
	}

	//金额1回车
	onPressEnter1 = () => {
		let { payType, otherPay, otherPayDis } = this.state
		if (otherPayDis) {
			if (payType === '7' || otherPay === '7') {  //合作记账单位
				setTimeout(() => {
					this.myRef5.current.focus();
				}, 300)
			} else {
				setTimeout(() => {
					this.myRef6.current.focus();
				}, 300)
				// this.chargingConfir() //确认收费
			}

		} else {
			setTimeout(() => {
				this.myRef3.current.focus();
			}, 300)
		}



	}

	//金额1回车
	onPressEnter2 = () => {
		let { payType, otherPay, otherPayDis } = this.state
		if (payType === '7' || otherPay === '7') {  //合作记账单位
			setTimeout(() => {
				this.myRef5.current.focus();
			}, 300)
		} else {
			setTimeout(() => {
				this.myRef6.current.focus();
			}, 300)
			// this.chargingConfir() //确认收费
		}
	}

	onRefPatPay = (ref) => {

		this.childfPatPay = ref

	}

	hideModal(name) {
		this.setState({
			[name]: false
		})
	}

	//人脸识别
	handleShowFaceRecognition() {
		this.setState({
			isShowFaceRecognitionModal: true
		}, () => {
			var { clearData } = this.props;
			clearData && clearData()
		})
	}

	loadCallBackMsg(data) {
		this.setState({
			patNo: data
		}, () => {
			this.searchUser()
		})
	}

	onRef = ref => {
		this.onFace = ref
	}
	discountOnRef = ref => {
		this.discountChild = ref
	}
	discountOnClick = () => {
		if (this.state.admID) {
			this.setState({ discountShow: true })
			if (this.discountChild) {
				this.discountChild.medicalInformation(this.state.admID);
			}
		}
	}
	modalOnRef = (ref) => {
		this.modalChild = ref
	}
	// 诊断回车事件
	itmOnPressEnter = () => {
		let top = document.getElementById('inputDiag-id').getBoundingClientRect().top + 30 + 'px';
		let left = document.getElementById('inputDiag-id').getBoundingClientRect().left + 'px';
		this.setState({
			top,
			left
		});
		this.getModalListData(this.state.searchCode);
		//
	}

	itmOnChange = (e) => {
		if (!e.target.value) {
			this.setState({
				searchCode: '',
				INSUICDDesc: '',
				INSUICDCode: '',
				xnhBCTYPE:'',
			})
		} else {
			this.setState({ searchCode: e.target.value })
		}
	}
	// 修改结算类型
	comepnCodeonChange = (val, opt) => {
		this.setState({
			comepnCode: val,
		});
	}
	//险种类型
	insuTypeonChange = (val, opt) => {
		this.setState({
			insuType: val,
		});
	}
	//统筹区
	insuAdmdvsonChange = (val, opt) => {
		this.setState({
			insuAdmdvs: val,
		});
	}

	//险种类型
	insuMedTypeonChange = (val, opt) => {
		this.setState({
			insuMedType: val,
		});
	};
	diseCodeonChange = (val, opt) => {
		this.setState({
			diseCode: val,
			diseDesc:opt.title
		});
	};
	birctrlTypeonChange = (val, opt) => {
		this.setState({
			birctrlType: val
		});
	};
	insuMdtrtGrpTypeonChange = (val, opt) => {
		this.setState({
			insuMdtrtGrpType: val
		});
	};
	handleChangeSwitch(name, e) {
        this.setState({
            [name]: e ? 'Y' : 'N'
        })
    }
	handleChangeDatePicker(name, e) {
        var date = new Date()
        if (name == 'startDate') {
            this.setState({
                [name]: e ? moment(e).format(dayFormat) : moment(date).format(dayFormat)
            })
        } else {
            this.setState({
                [name]: e ? moment(e).format(dayFormat) : ''
            })
        }
    }

	// 就诊凭证类型
	certTypeonChange = (val, opt) => {
		this.setState({
			certType: val,
		});
	}
	// 就诊凭证编号
	certNoChange = e => {
		this.setState({ certNo: e.target.value })
	}

	handleCompilePage = (page, pageSize) => {
		this.setState({ modalPageSize: pageSize, modalPage: page }, () => {
			this.getModalListData(this.state.searchCode);
		})
	}

	// 获取描述列表数据
	getModalListData(searchCode) {
		let { modalPageSize, modalPage, pageSize, page, admReasomID } = this.state;
		let data = {
			params: [
				{
					searchCode: searchCode,
					admReasomID,
					treatCode: (treatCode),			//
				}
			],
			pagination: [{
				pageSize: modalPageSize,
				currentPage: modalPage,
				sortColumn: "Describe",
				sortOrder: "asc"
			}]
		}
		$http.post('urlS', this, {
			code: "05210068",
			data: data,
			success: function (res) {
				if (res.errorCode == '0') {
					var source = res.result.data
					for (var i = 0; i < source.length; i++) {
						source[i].key = i + 1
					}
					this.setState({ modalData: source, modalTotal: res.result.totalCount }, () => {
						this.modalChild.showModal();
					})
				} else {
					this.setState({ modalData: [], modalTotal: 0 })
				}
			}
		})
	}
	// 下拉table双击
	onClickRowPublic = (record) => {
		return {
			onDoubleClick: () => {
				this.setState({
					INSUICDCode: record.code,
					INSUICDDesc: record.descripts,
					searchCode: ''
				}, () => this.modalChild.handleCancel())
			}
		}

	}
	setRowClassNamePublic = () => {
		// return (record.id) === this.state.diagID ? 'clickRowStyle' : '';
	}
	closeDiscountModal = () => {
		this.setState({discountShow: false})
		this.costTypeHttp('', '0', '', '')
	}
	render() {
		let { dataAdmReason, columnsPatCharSome, moneyData, tabKey, selectedRowKeys2, language, userInfo, modalTotal, modalPage, top, left, modalData } = this.state
		let setRowClassName = this.setRowClassName

		let selectedRowKeys = this.state.selectedRowKeys[tabKey]



		let rowSelection = {
			selectedRowKeys: selectedRowKeys,
			onChange: this.onSelectChange,
			getCheckboxProps: record => ({
				disabled: (record.ordSelect === 'N' ? true : false),
			}),
		};

		let rowSelection2 = {
			selectedRowKeys: selectedRowKeys2,
			onChange: this.rowSelectionOnChange,
			getCheckboxProps: record => ({
				disabled: (record.ordSelect === 'N' ? true : false),
			}),
		};
		let itemselect = this.state.settlementTypeData.filter((item) => {
			return item.id == this.state.PayReasonDr;
		})
		let nameplaceholder = "请输入医保卡号回车"
		let inputname = "医保卡号:"
		if (itemselect && itemselect.length > 0) {
			if (itemselect[0].code === "INSUHFXNHY") {
				inputname = "医疗证号:"
				nameplaceholder = "请输入医疗证号回车"
			}

		}
		const modalParam = {
			width: '600px',
			total: modalTotal,
			page: modalPage,
			top: top,
			left: left,
			columns: this.modalColumns,
			data: modalData,
			isOnRow: true,
			showPagination: true,
		}

		let windowHost = window.location && window.location.origin ? window.location.origin : (window.location && window.location.protocol ? (window.location.protocol + '//' + window.location.hostname) : "");
		let patientUrl = !Util.isEmpty(userInfo) ? userInfo.patImage : ''
		var patientImg = patientUrl ? (patientUrl.indexOf("http") !== -1 ? patientUrl : windowHost + patientUrl) : '';

		return (
			<div className="patient-charges-shizi">
				{/**列input框新表格弹框 */}
				<PublicModalTable
					onClickRowPublic={this.onClickRowPublic}
					setRowClassNamePublic={this.setRowClassNamePublic}
					param={modalParam}
					onRef={this.modalOnRef}
					compilePage={this.handleCompilePage}
				/>
				{/**人脸识别 */}
				<ShowFaceRecognitionModal isShow={this.state.isShowFaceRecognitionModal}
					businessCode='005' onRef={this.onRef}
					onSubmit={this.loadCallBackMsg.bind(this)}
					onHide={this.hideModal.bind(this, 'isShowFaceRecognitionModal')}>
				</ShowFaceRecognitionModal>
				<ReadCard ref={r => this.readCard = r} />
				{/* <OtherCashRegister  /> */}
				<div className="table-operations">
					<Row>
						<Col span={24} style={{ display: "flex", alignItems: "center" }}>
							<Select allowClear style={{ width: '146px', marginLeft: "20px" }} placeholder={language.PatientChargesChargeStatus && language.PatientChargesChargeStatus.message} value={this.state.cardType} onChange={(event) => { this.cardType(event) }}  >
								<Option value=''>{language.PatientChargesChargeStatus && language.PatientChargesChargeStatus.message}</Option>
								{this.state.cardTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
							</Select>
							<Search maxLength={50} ref={(input) => { this.cardNoInput = input; }} className={`search ${!this.state.readModeI ? 'disabled' : ''}`} style={{ width: '220px', marginLeft: "20px", marginRight: "20px" }} allowClear placeholder={language.PatientChargesLoadCard && language.PatientChargesLoadCard.message} disabled={this.state.disabledInput} value={this.state.cardNo} enterButton={language.PatientChargesLoadCard && language.PatientChargesLoadCard.descripts} onChange={(event) => { this.cardNo(event) }} onSearch={this.handleReadCard} /> {/* onKeyUp={(e) => { this.handleReadCarddownE(e, 'cardNo'); }}*/}
							<span className="pcs-form-label">{language.PatientChargesPersonIdentification && language.PatientChargesPersonIdentification.descripts}：</span><Input maxLength={50} ref={(input) => { this.patNoInput = input; }} style={{ width: '200px', marginRight: "20px" }} allowClear placeholder={language.PatientChargesPersonIdentification && language.PatientChargesPersonIdentification.message} disabled={this.state.disabledInput} className='input' value={this.state.patNo} onChange={(event) => { this.patNo(event) }} onKeyUp={(e) => { this.patNodownE(e, 'patNo'); }} />

							<span className="pcs-form-label">{language.PatientChargesChargeDate && language.PatientChargesChargeDate.descripts}：</span><span style={{ display: 'inline-block', marginRight: "20px" }} className="pcs-picker"><RangeDatePicker label="" format='YYYY-MM-DD' width={280}
								startDate={this.state.StartDate} endDate={this.state.EndDate} startChange={this.startChange.bind(this)} endChange={this.endChange.bind(this)} /></span>
							<span className="pcs-form-label">{language.PatientChargesChargeStatus && language.PatientChargesChargeStatus.descripts}：</span><Select allowClear style={{ width: '122px' }} placeholder="请选择" value={this.state.findCondition} onChange={(event) => { this.findCondition(event) }} className="pcs-select" >
								<Option value='N'>全部</Option>
								<Option value='Y'>未收费</Option>
							</Select>
							<Button type="primary" onClick={() => this.searchUser()} style={{ marginLeft: "20px" }}>{language.PatientChargesQuery && language.PatientChargesQuery.descripts}</Button>
							<Button type={"primary"} style={{ marginLeft: 20 }} onClick={this.handleShowFaceRecognition.bind(this)}>人脸识别</Button>
							<Button type="primary" ghost onClick={() => this.modalShowHis()} style={{ marginLeft: "20px" }}>{language.PatientChargesQueryRecords && language.PatientChargesQueryRecords.descripts}</Button>
						</Col>
					</Row>
				</div>
				<div className="pcs-center">
					<Row >
						<Col span={6} style={{ textAlign: 'center' }}>
							<div style={{ height: "205px", padding: "20px", boxSizing: "border-box", background: "#fff", display: "flex" }}>
								{!Util.isEmpty(patientUrl) ? <img className='splice-patient-img' src={patientImg} style={{ width: '134px', height: '165px' }} /> : <div style={{
									background: `url(${userInfo && userInfo.patSexCode == "1" ? avatarMale :
										(userInfo.patSexCode == "2" ? avatarFemale : avatarMale)})`, width: "134px", height: "165px"
								}}></div>}

								<div style={{ width: "calc(100% - 134px)", textAlign: "left", paddingLeft: "20px", boxSizing: "border-box" }}>
									<div>
										<span style={{ display: !Util.isNull(userInfo) ? 'none' : 'block', color: "#333", height: "53px" }} > <i className='unknow'></i> ——</span>
									</div>
									<div style={{ display: Util.isNull(userInfo) ? 'none' : 'block' }}>
										<div>
											<span className="margin-right-12" style={{ fontSize: "16px", color: "#333" }}>{userInfo && userInfo.patName ? userInfo.patName : "姓名"}</span>
											<span className="margin-right-12 font14color999">{userInfo && userInfo.patSexDesc ? userInfo.patSexDesc : "性别"}</span>
											<span className="margin-right-12 font14color999">{userInfo && userInfo.patAge ? userInfo.patAge : "年龄"}</span>
											<span className="font14color999">{userInfo && userInfo.patNo ? userInfo.patNo : "登记号"}</span>
										</div>
										<div className="pc-icon" style={{ margin: "12px 0", fontSize: "14px", color: "#333", display: "flex", alignItems: "center" }}>
											<span className="pc-icon-span pc-icon-expense"></span>
											<span>{userInfo && userInfo.patTypeDesc ? userInfo.patTypeDesc : "--"}</span>
											<Divider type="vertical" />
											<span className="pc-icon-span pc-icon-employee"></span>
											<span>{userInfo && userInfo.patSocialStatusDesc ? userInfo.patSocialStatusDesc : "--"}</span>
											<Divider type="vertical" />
											<span className="pc-icon-span pc-icon-money"></span>
											<span>{userInfo && userInfo.totalBalance ? userInfo.totalBalance : "--"}</span>
										</div>
									</div>
									<div className="all-pat-price">
										<div className="price all-price">
											<span>￥{this.state.allPrice} </span>
											费用总额
										</div>
										<div className="price pat-price">
											<span>￥{this.state.allPatPrice} </span>
											应付金额
										</div>
									</div>
									<div style={{ display: "flex", justifyContent: "center", marginTop: "12px" }}>
										<span className="pcs-form-label">{language.PatientChargesBillingType && language.PatientChargesBillingType.descripts}：</span>
										<Select className="pcs-select" style={{ width: "169px" }} allowClear placeholder={language.PatientChargesBillingType && language.PatientChargesBillingType.descripts} value={this.state.PayReasonDr} onChange={(event) => { this.PayReasonDr(event) }} >
											{this.state.settlementTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
										</Select>
									</div>
								</div>
							</div>
							{/* <Row >
								<Col span={23} >
									<TipHeader userInfo={this.state.userInfo} key={this.state.userInfo.patID + this.state.userInfo.accTSubID} />
								</Col>
							</Row>
							<Row style={{ position: "relative" }}>
								<Col span={24} style={{ paddingRight: "6px" }}>
									<Col span={24} style={{ height: '40px', lineHeight: '40px', textAlign: 'left' }} ><i className="invPng"></i><span>{language.PatientChargesCurrentInvoiceNumber && language.PatientChargesCurrentInvoiceNumber.descripts}:</span><span className='curP' style={{ color: '#1890FF', }} onClick={() => { this.historyModal() }} > {this.state.invoice ? this.state.invoice.split('^')[2] : ''}</span> <span style={{ color: 'red', float: 'right', marginRight: '20px', display: parseFloat(this.state.invNum) < 10 ? 'block' : 'none' }}>{language.PatientChargesInvoicesurplus && language.PatientChargesInvoicesurplus.descripts}{this.state.invNum},{language.PatientChargesPleasepurch && language.PatientChargesPleasepurch.descripts}</span></Col>
									<Col span={12} >
										<div className='boxTitle'><i className="money1"></i>{language.PatientChargesTotalAmount && language.PatientChargesTotalAmount.descripts}</div>
										<div className='priceBox'>
											<span style={{ fontSize: '14px', color: '#CCCCCC' }}>￥</span> <span>{this.state.allPrice} </span>
										</div>
									</Col>
									<Col span={12}  >
										<div className='boxTitle'><i className="money2"></i>{language.PatientChargesPatientPayable && language.PatientChargesPatientPayable.descripts}</div>
										<div className='priceBox'>
											<span style={{ fontSize: '14px', color: '#CCCCCC' }}>￥</span> <span>{this.state.allPatPrice} </span>
										</div>
									</Col>
									<Col span={24} className="mT15" style={{display: "flex", justifyContent: "center"}} >
										<span className="pcs-form-label">{language.PatientChargesBillingType && language.PatientChargesBillingType.descripts}：</span>
										<Select className="pcs-select"style={{ width: "169px" }} allowClear placeholder={language.PatientChargesBillingType && language.PatientChargesBillingType.descripts} value={this.state.PayReasonDr} onChange={(event) => { this.PayReasonDr(event) }} >
											{this.state.settlementTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
										</Select>
									</Col>
								</Col>
							</Row> */}
							<div
								style={{
									height: '100%',
									background: 'rgb(240, 242, 245)',
									position: 'absolute',
									right: '0px',
									top: '0px',
									width: "6px"
								}} >
							</div>
						</Col>
						<Col span={18}>
							<Table
								bordered
								dataSource={this.state.dataPatChar}
								columns={this.state.columnsPatChar}
								pagination={false}
								rowSelection={this.state.IfAllAdmPay !== 'Y' ? null : rowSelection2}
								className="smallTable"
								scroll={{ y: 160 }}
								style={{ height: '205px' }}
								onRow={(record) => {
									return {
										onClick: (event) => {
											this.costType(record)
										},
									};
								}}
								rowClassName={this.setRowClassNameSelect}
							/>

						</Col>
					</Row>
				</div>
				<div style={{ background: '#f0f2f5', height: '6px' }}></div>
				<div style={{ background: "#fff", padding: "0 20px", height: store.getState().tableHeight.y - 42 + 'px', position: "relative" }}>
					<div style={{ position: 'absolute', top: "10px", right: "20px", zIndex: 1, display: "flex", alignItems: "center" }}>
						{/* <span>{language.PatientChargesCurrentInvoiceNumber && language.PatientChargesCurrentInvoiceNumber.descripts}:</span> */}
						<span className='curP' style={{ color: '#1890FF', }} onClick={() => { this.historyModal() }} > {this.state.invoice ? this.state.invoice.split('^')[2] : ''}</span>
						{this.state.groupConfig&&this.state.groupConfig.IfInvNo === 'Y'?
							<span style={{ color: 'red', marginRight: '20px', display: parseFloat(this.state.invNum) < 10 ? 'block' : 'none' }}>{language.PatientChargesInvoicesurplus && language.PatientChargesInvoicesurplus.descripts}{this.state.invNum},{language.PatientChargesPleasepurch && language.PatientChargesPleasepurch.descripts}</span>
							:
							<span style={{ color: 'red', marginRight: '20px', display: parseFloat(this.state.invNum) < 10 ? 'block' : 'none' }}></span>
						}
						<Button type="primary" onClick={() => this.payButton()} style={{ margin: "0 20px" }}><i className="icon-money-act"></i>{language.PatientChargesCashRegister && language.PatientChargesCashRegister.descripts}</Button>
						<Button type="primary" onClick={this.discountOnClick} style={{ marginRight: "20px" }}><i className="icon-money-act"></i>{'优惠'}</Button>
						<Button type="primary" ghost onClick={this.clearnFile}><i className="clearn"></i>{language.PatientChargesClear && language.PatientChargesClear.descripts}</Button>
					</div>
					<Row>
						<i className="cost-type"></i>
						<Tabs defaultActiveKey="0" onChange={this.TabChange} activeKey={this.state.activeKey}>
							{this.state.orderAdmReason.map(function (item, i) {
								return (
									<TabPane tab={item.ordReasonDesc} key={i}  >
										<Table
											className='maxHeight'
											bordered
											dataSource={dataAdmReason[i]}
											columns={columnsPatCharSome}
											pagination={false}
											// style={{ minHeight: (store.getState().tableHeight.y) - 278 + 'px' }}
											scroll={{ y: (store.getState().tableHeight.y) - 176, x: 1500 }}
											rowSelection={rowSelection}
											rowClassName={`${setRowClassName}`}
										/>
									</TabPane>)
							})}

						</Tabs>
					</Row>

				</div>
				{/* 历史就诊记录弹框 */}
				<Modal
					visible={this.state.modalShowHis}
					title='查询就诊记录'
					onCancel={this.handleCancel}
					onOk={this.handleCancel}
					width='900px'
					footer={null}
				>
					<HistoryModal StartDate={this.state.StartDate} EndDate={this.state.EndDate} userInfo={this.state.userInfo} updateParent={this.updateParent} key={this.state.userInfo.patID} ></HistoryModal>
				</Modal>
				{/* 设置发票号弹框 */}
				<Modal
					visible={this.state.modalShow}
					title='设置发票号'
					onCancel={this.handleCancel}
					onOk={this.handleCancel}
					width='600px'
					footer={null}
				>
					{/* <HistoryModal userInfo={this.state.userInfo} updateParent={this.updateParent}></HistoryModal> */}
					<HopNumber invTypeCode='O' key={this.state.invoice} handleCancel={this.handleCancel} handelThis={this} />

				</Modal>
				{/* 收银弹框 */}
				<Modal
					visible={this.state.modalShowPay}
					title={this.state.modalPayTitle}
					onCancel={this.handleCancel}
					onOk={this.payButtonVerfiyOk}
					width={this.state.modalShowPayWidth}
					className='modalPay'
					maskClosable={false}
					footer={null}
				>

					<div style={{ display: 'block' }}>
						<PatPayModal patID={this.state.userInfo.patID} onRef={this.onRefPatPay} chargeRecodeId={this.state.chargeRecodeId} key={this.state.chargeRecodeId} MakeMoney={this.MakeMoney} handthis={this} password={this.state.password} personalData={this.state.personalData} />
					</div>
					<div style={{ textAlign: 'right', margin: '10px 0' }}>
						<Button onClick={this.RollBACKOPCharge} style={{ marginRight: '20px' }}>取消</Button>
						<Input ref={this.myRef6} type="primary" value="确定" readOnly="readOnly" onClick={this.payButtonVerfiyOk} style={{ textAlign: 'center', backgroundColor: '#1999db', width: '60px', color: '#fff', cursor: 'pointer' }} onPressEnter={this.payButtonVerfiyOk} />
					</div>
				</Modal>
				<Modal
					title="请输入医保卡号或扫描电子凭证医保码"
					visible={this.state.cardShow}
					onOk={this.YBInputSure}
					onCancel={() => this.setState({ cardShow: false })}>
					<Row style={{ marginTop:'10px' }}>
						<Col span={6} style={{ paddingTop:'4px' }}>就诊凭证类型:</Col>
						<Col span={18}>
							<Select style={{ width:'320px' }} value={this.state.certType} onChange={this.certTypeonChange} >
								{/*this.state.comepnCodeList && Array.isArray(this.state.comepnCodeList) && this.state.comepnCodeList.map((item, index) => <Option title={item.subDesc} key={index} value={item.subCode} >{item.subDesc}</Option>)*/}
								<Option value='01'>电子凭证令牌</Option>
								<Option value='02'>身份证号</Option>
								<Option value='03'>社会保障卡</Option>
							</Select>
						</Col>
					</Row>
					<Row style={{ marginTop:'10px' }}>
						<Col span={6} style={{ paddingTop:'4px' }}>就诊凭证编号:</Col>
						<Col span={18}><Input  style={{width: '320px'}}  value={this.state.certNo} onChange={(e) => this.certNoChange(e)} onPressEnter={this.YBInputSure}/></Col>
					</Row>
					<Row style={{ marginTop:'10px' }}>
						<Col span={6} style={{ paddingTop:'4px' }}>统筹区:</Col>
						<Col span={18}>
							<Select style={{ width: '320px'}} value={this.state.insuAdmdvs} onChange={this.insuAdmdvsonChange} showSearch optionFilterProp="seatchprop" allowClear >
								{this.state.insuAdmdvsList && Array.isArray(this.state.insuAdmdvsList) && this.state.insuAdmdvsList.map((item, index) => <Option title={item.descripts} key={index} value={item.code} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)}
							</Select>
						</Col>
					</Row>
				</Modal>

				{/* 城乡医保 */}
				<Modal
					title="收银"
					visible={this.state.nameAndIDNumberVisible}
					onOk={this.YBInputSure}
					onCancel={() => this.setState({ nameAndIDNumberVisible: false })}
				>
					身份证号<Input placeholder="请输入身份证号" value={this.state.patCard} onChange={this.handlePatCardChange} onPressEnter={this.YBInputSure}></Input>
					姓名:<Input placeholder="请输入姓名" value={this.state.patName} onChange={this.handlePatNameChange} onPressEnter={this.YBInputSure}></Input>
				</Modal>

				{/* 医保病人信息 */}
				<Modal
					title='医保病人信息'
					visible={this.state.insuInfoShow}
					onCancel={() => this.setState({ insuInfoShow: false })}
					okText="确定"
					onOk={this.closeModal}
					width={1000}
				>
					<div>
						<Row className="ybpat-row">
							{this.state.divdata.map((item, index) => {
								return <Col className="ybpat-col" span={6} key={index}>
									<span className="ybpat-desc">{item.desc}</span>
									<span>：</span>
									<span className="ybpat-value">{item.value}</span>
								</Col>
							})}
						</Row>
						<Row gutter={10} style={{marginBottom:'10px'}}>
							<Col span={8} >
								<Row gutter={4}>
									<Col span={8} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>险种类型:</span>
									</Col>
									<Col span={16}>
										<Select style={{ width: '96%' }} value={this.state.insuType} onChange={this.insuTypeonChange} >
											{this.state.insuTypeList && Array.isArray(this.state.insuTypeList) && this.state.insuTypeList.map((item, index) => <Option title={item.descripts} key={index} value={item.code} >{item.descripts}</Option>)}
										</Select>
									</Col>
								</Row>
							</Col>
							<Col span={8} >
								<Row gutter={4}>
									<Col span={8} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>医疗类别:</span>
									</Col>
									<Col span={16}>
										<Select style={{ width: '96%' }} value={this.state.insuMedType} onChange={this.insuMedTypeonChange} >
											{this.state.insuMedTypeList && Array.isArray(this.state.insuMedTypeList) && this.state.insuMedTypeList.map((item, index) => <Option title={item.descripts} key={index} value={item.code} >{item.descripts}</Option>)}
										</Select>
									</Col>
								</Row>
							</Col>
							<Col span={8} >
								<Row gutter={4}>
									<Col span={8} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>病种编码:</span>
									</Col>
									<Col span={16}>
										<Select style={{ width: '96%'}} value={this.state.diseCode} onChange={this.diseCodeonChange} >
											{this.state.diseCodeList && Array.isArray(this.state.diseCodeList) && this.state.diseCodeList.map((item, index) => <Option title={item.descripts} key={index} value={item.code} >{item.descripts}</Option>)}
										</Select>
									</Col>
								</Row>
							</Col>
						</Row>
						<Row gutter={10} style={{marginBottom:'10px'}}>
							<Col span={8}>
								<Row gutter={4}>
									<Col span={10} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>计划生育手术类别:</span>
									</Col>
									<Col span={14}>
										<Select style={{ width: '96%' }} value={this.state.birctrlType} onChange={this.birctrlTypeonChange} >
											{this.state.birctrlTypeList && Array.isArray(this.state.birctrlTypeList) && this.state.birctrlTypeList.map((item, index) => <Option title={item.descripts} key={index} value={item.code} >{item.descripts}</Option>)}
										</Select>
									</Col>
								</Row>
							</Col>
							<Col span={8} >
								<Row gutter={4}>
									<Col span={8} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>手术日期:</span>
									</Col>
									<Col span={16}>
										<DatePicker style={{ width: '96%' }} onChange={this.handleChangeDatePicker.bind(this, 'birctrlDate')} placeholder='请选择日期'
													value={this.state.birctrlDate ? moment(this.state.birctrlDate, dayFormat) : ''} format={dayFormat} />
									</Col>
								</Row>
							</Col>
							<Col span={8} >
								<Row gutter={4}>
									<Col span={8} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>使用帐户标志:</span>
									</Col>
									<Col span={16}>
										<Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.userAccFlag === 'Y'}
												onChange={this.handleChangeSwitch.bind(this, 'userAccFlag')} />
									</Col>
								</Row>
							</Col>
						</Row>
						<Row gutter={10} style={{marginBottom:'10px'}}>
							<Col span={8}>
								<Row gutter={4}>
									<Col span={8} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>就诊人群类型:</span>
									</Col>
									<Col span={16}>
										<Select style={{ width: '96%' }} value={this.state.insuMdtrtGrpType} onChange={this.insuMdtrtGrpTypeonChange}>
											{this.state.insuMdtrtGrpTypeList && Array.isArray(this.state.insuMdtrtGrpTypeList) && this.state.insuMdtrtGrpTypeList.map((item, index) => <Option title={item.descripts} key={index} value={item.code} >{item.descripts}</Option>)}
										</Select>
									</Col>
								</Row>
							</Col>
							<Col span={8} >
								<Row gutter={4}>
									<Col span={8} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>外伤标志:</span>
									</Col>
									<Col span={16}>
										<Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.traumaFlag === 'Y'}
												onChange={this.handleChangeSwitch.bind(this, 'traumaFlag')} />
									</Col>
								</Row>
							</Col>
							<Col span={8} >
								<Row gutter={4}>
									<Col span={8} align='right' justify='center'  style={{paddingTop:'4px'}}>
										<span>第三方标志:</span>
									</Col>
									<Col span={16}>
										<Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.thirdFlag === 'Y'}
												onChange={this.handleChangeSwitch.bind(this, 'thirdFlag')} />
									</Col>
								</Row>
							</Col>
						</Row>

					</div>
				</Modal>
				<div>
					{this.state.admID ?
						<Modal
							title="优惠折扣" className='discount-modal'
							visible={this.state.discountShow}
							onOk={() => this.setState({ discountShow: false })}
							onCancel={() => this.setState({ discountShow: false }, () => {
								this.costTypeHttp('', '0', '', '') // 收费类型接口
							})}
							footer={false}
						>
							<PatientAdmOrderCharges
								admID={this.state.admID}
								patID={this.state.userInfo.patID}
								userInfo={this.state.userInfo}
								onRef={this.discountOnRef}
								closeModal={this.closeDiscountModal}
							/>
						</Modal> : null}
				</div>
			</div>
		)
	}
}
